﻿namespace Hopfield.Simulator.WPF
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Forms.DataVisualization.Charting;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;    

    /// <summary>
    /// Interaction logic for ChartWindow.xaml
    /// </summary>
    public partial class ChartWindow : Window
    {
        private Chart mainChart = new Chart();

        public ChartWindow()
        {
            this.InitializeComponent();
            this.mainChart.Name = "mainChart";
            this.mainChart.Dock = System.Windows.Forms.DockStyle.Fill;
            ChartArea chartArea = new ChartArea()
            {
                Name = "ValuesChartArea"
            };
            this.mainChart.ChartAreas.Add(chartArea);
            Legend legend = new Legend()
            {
                Enabled = false,
                Name = "ValuesLegend"
            };
            this.mainChart.Legends.Add(legend);
            Series series = new Series()
            {
                ChartArea = "ValuesChartArea",
                ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line,
                IsXValueIndexed = true,
                Legend = "ValuesLegend",
                Name = "Values"
            };
            this.mainChart.Series.Add(series);
            this.mainChart.TabIndex = 0;
            this.mainChart.Text = "Values Chart";
            winFormsHost.Child = mainChart;
        }

        public void AddValue(float value)
        {
            this.mainChart.Series[0].Points.AddY(value);
        }

        public void ClearValues()
        {
            this.mainChart.Series[0].Points.Clear();
        }

        public void SetValuesName(string name)
        {
            this.Title = string.Format(CultureInfo.InvariantCulture, "Chart {0} values.", name);
        }
    }
}
